package com.elong.businesstravel.protocol.hotel;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONObject;

import com.elong.businesstravel.entitys.HotelCollect;
import com.elong.businesstravel.protocol.baseresponse.BaseELongJsonHttpResponse;

public class GetCollectionResponse extends BaseELongJsonHttpResponse {
	
	protected List<HotelCollect> hotelCollects = new ArrayList<HotelCollect>();

	@Override
	public void onSuccess(int statusCode, Header[] headers,
			JSONObject mainJsonObject) throws Throwable {
		JSONObject responseJsonObject = mainJsonObject.optJSONObject("response");
		if(null != responseJsonObject){
			JSONArray hotelJsonArray = responseJsonObject.optJSONArray("hotel");
			if(null != hotelJsonArray){
				for (int i = 0; i < hotelJsonArray.length(); i++) {
					HotelCollect hotelCollect = new HotelCollect();
					JSONObject itemJsonObject = hotelJsonArray.optJSONObject(i);
					if(null != itemJsonObject){
						hotelCollect.hotelid = itemJsonObject.optString("hotelid", "");
						hotelCollect.hotelname = itemJsonObject.optString("hotelname", "");
						hotelCollect.address = itemJsonObject.optString("address", "");
						hotelCollects.add(hotelCollect);
					}
				}
			}
		}
	}

}
